{{csrf_field()}}
<div class="layui-form-item">
    <label for="" class="layui-form-label">所属楼盘</label>
    <div class="layui-input-block">
        <div class="layui-input-inline" style="display: flex;align-items: center;">
            @if($property_id)
                <input id="proname" readonly value="{{$property->title}}" class="layui-input" />
            @else
                <input id="proname" readonly value="{{$article->property->title??''}}" class="layui-input" />
            @endif
            <i class="layui-icon layui-icon-close" id="clearName" @if(!empty($article->property->title) || $property_id) style="display:inline;" @endif></i>
        </div>
        <input type="hidden" id="propertyid" name="property_id" value="{{ $article->property_id??$property_id }}">
        <button type="button" id="selProperty" class="layui-btn layui-btn-normal">选择楼盘</button>
    </div>
</div>
<div class="layui-form-item">
    <label for="" class="layui-form-label">分类*</label>
    <div class="layui-input-inline">
        <select name="category_id" lay-verify="required">
            <option value=""></option>
            @foreach($categorys as $category)
                <option value="{{ $category->id }}" @if(isset($article->category_id)&&$article->category_id==$category->id)selected @endif >{{ $category->name }}</option>
                @if(isset($category->allChilds)&&!$category->allChilds->isEmpty())
                    @foreach($category->allChilds as $child)
                        <option value="{{ $child->id }}" @if(isset($article->category_id)&&$article->category_id==$child->id)selected @endif >&nbsp;&nbsp;&nbsp;┗━━{{ $child->name }}</option>
                        @if(isset($child->allChilds)&&!$child->allChilds->isEmpty())
                            @foreach($child->allChilds as $third)
                                <option value="{{ $third->id }}" @if(isset($article->category_id)&&$article->category_id==$third->id)selected @endif >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;┗━━{{ $third->name }}</option>
                            @endforeach
                        @endif
                    @endforeach
                @endif
            @endforeach
        </select>
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">标题*</label>
    <div class="layui-input-block">
        <input type="text" name="title" value="{{$article->title??old('title')}}" lay-verify="required" placeholder="请输入标题" class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">所属地区</label>
    <div class="layui-input-inline">
        <select name="province" id="province" lay-verify="required" lay-filter="myselect">
            <option value="0">全国</option>
            @if($province)
            @foreach($province as $pr)
                <option value="{{$pr->id}}" @if(isset($article->province) && $pr->id == $article->province) selected @endif >{{$pr->name}}</option>
            @endforeach
            @endif
        </select>
    </div>
    <div class="layui-input-inline region-sel" id="city" @if(isset($article->region_id) && $article->region_id > 0) style="display:inline;" @endif>
        <select name="region_id" id="region" lay-verify="required" lay-filter="myselect2" ></select>
    </div>
    <input type="hidden" id="province_id" value="{{$article->province??0}}">
    <input type="hidden" id="region_id" value="{{$article->region_id??0}}">
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">标签</label>
    <div class="layui-input-block">
        @foreach($tags as $tag)
            <input type="checkbox" name="tags[]" lay-skin="primary" {{ $tag->checked??'' }} value="{{ $tag->id }}" title="{{ $tag->name }}">
        @endforeach
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">推荐位</label>
    <div class="layui-input-block">
        <input type="checkbox" name="recommend[]" value="h" @if(!empty($article->recommend) &&  in_array('h',$article->recommend)) checked @endif title="头条[h]" lay-skin="primary">
        <input type="checkbox" name="recommend[]" value="c" @if(!empty($article->recommend) &&  in_array('c',$article->recommend)) checked @endif title="推荐[c]" lay-skin="primary">
        <input type="checkbox" name="recommend[]" value="r" @if(!empty($article->recommend) &&  in_array('r',$article->recommend)) checked @endif title="热门[r]" lay-skin="primary">
    </div>
</div>
<div class="layui-form-item">
    <label for="" class="layui-form-label">关键词</label>
    <div class="layui-input-block">
        <input type="text" name="keywords" value="{{$article->keywords??old('keywords')}}" placeholder="请输入关键词" class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">描述</label>
    <div class="layui-input-block">
        <textarea name="description" placeholder="请输入描述" class="layui-textarea">{{$article->description??old('description')}}</textarea>
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">点击量</label>
    <div class="layui-input-block">
        <input type="number" name="click" value="{{$article->click??mt_rand(100,500)}}" lay-verify="required|numeric"  class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">缩略图</label>
    <div class="layui-input-block">
        <div class="layui-upload">
            <button type="button" class="layui-btn layui-btn-normal" id="uploadPic"><i class="layui-icon">&#xe67c;</i>图片上传</button>
            <div class="layui-upload-list" >
                <ul id="layui-upload-box" class="layui-clear">
                    @if(isset($article->thumb))
                        <li><img src="{{ $article->thumb }}" /><p>上传成功</p></li>
                    @endif
                </ul>
                <input type="hidden" name="thumb" id="thumb" value="{{ $article->thumb??'' }}">
            </div>
        </div>
    </div>
</div>

@include('UEditor::head')
<div class="layui-form-item">
    <label for="" class="layui-form-label">内容</label>
    <div class="layui-input-block">
        <script id="container" name="content" type="text/plain">
            {!! $article->content??old('content') !!}
        </script>
    </div>
</div>

<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formDemo">确 认</button>
        <a  class="layui-btn" href="{{route('admin.article')}}" >返 回</a>
    </div>
</div>